package com.pg_chat.model;


import java.sql.Timestamp;
import java.util.*;

public class UserEntity {

    private Integer userId;
    private Integer userState;
    private Short age;
    private Short sex;
    private String password;
    private String username;
    private String regAddr;
    private String emailAddr;
    private String phoneNumber;
    private String IdCard;
    private String signature;
    private String intro;
    private String headPortrait;
    private Date birthday;
    private Timestamp createTime;
    private Date updateTime;
    private Boolean isBan;
    private Boolean isBandEmail;
    private Boolean isBandPhone;
    private Boolean certification;

    public UserEntity() {
    }

    public Integer getUserState() {
        return userState;
    }

    public void setUserState(Integer userState) {
        this.userState = userState;
    }

    public Short getAge() {
        return age;
    }

    public void setAge(Short age) {
        this.age = age;
    }

    public Short getSex() {
        return sex;
    }

    public void setSex(Short sex) {
        this.sex = sex;
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getRegAddr() {
        return regAddr;
    }

    public void setRegAddr(String regAddr) {
        this.regAddr = regAddr;
    }

    public String getEmailAddr() {
        return emailAddr;
    }

    public void setEmailAddr(String emailAddr) {
        this.emailAddr = emailAddr;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getIdCard() {
        return IdCard;
    }

    public void setIdCard(String idCard) {
        IdCard = idCard;
    }

    public boolean isBan() {
        return isBan;
    }

    public void setBan(Boolean ban) {
        isBan = ban;
    }

    public boolean isBandEmail() {
        return isBandEmail;
    }

    public void setBandEmail(Boolean bandEmail) {
        isBandEmail = bandEmail;
    }

    public boolean isBandPhone() {
        return isBandPhone;
    }

    public void setBandPhone(Boolean bandPhone) {
        isBandPhone = bandPhone;
    }

    public boolean isCertification() {
        return certification;
    }

    public void setCertification(Boolean certification) {
        this.certification = certification;
    }

    public String getHeadPortrait() {
        String bas64Str = Base64.getEncoder()
                .encodeToString(headPortrait.getBytes());
        return bas64Str;
    }

    public void setHeadPortrait(String headPortrait) {
        this.headPortrait = headPortrait;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UserEntity)) return false;
        UserEntity that = (UserEntity) o;
        return isBan == that.isBan &&
            isBandEmail == that.isBandEmail &&
            isBandPhone == that.isBandPhone &&
            certification == that.certification &&
            userId.equals(that.userId) &&
            password.equals(that.password) &&
            username.equals(that.username) &&
            Objects.equals(regAddr, that.regAddr) &&
            Objects.equals(emailAddr, that.emailAddr) &&
            Objects.equals(phoneNumber, that.phoneNumber) &&
            Objects.equals(IdCard, that.IdCard);

    }

    public Map<String,Object> userMap(){
        HashMap<String,Object> map = new HashMap<>();
        map.put("userId",this.userId);
        map.put("password",this.password);
        map.put("username",this.username);
        map.put("phoneNumber",this.phoneNumber);
        map.put("emailAddr",this.emailAddr);
        map.put("birthday",this.birthday);
        map.put("age",this.age);
        map.put("sex",this.sex);
        map.put("userState",this.userState);
        map.put("signature",this.signature);
        map.put("intro",this.intro);
        map.put("createTime",this.createTime);
        map.put("updateTime",this.updateTime);
        map.put("headPortrait",this.headPortrait);
        return map;
    }

    @Override
    public String toString() {
        return "UserEntity{" +
                "userId=" + userId +
                ", userState=" + userState +
                ", age=" + age +
                ", sex=" + sex +
                ", password='" + password + '\'' +
                ", username='" + username + '\'' +
                ", regAddr='" + regAddr + '\'' +
                ", emailAddr='" + emailAddr + '\'' +
                ", phoneNumber='" + phoneNumber + '\'' +
                ", IdCard='" + IdCard + '\'' +
                ", signature='" + signature + '\'' +
                ", intro='" + intro + '\'' +
                ", headPortrait='" + headPortrait + '\'' +
                ", birthday=" + birthday +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", isBan=" + isBan +
                ", isBandEmail=" + isBandEmail +
                ", isBandPhone=" + isBandPhone +
                ", certification=" + certification +
                '}';
    }
}
